﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

public static class UnityExtension
{
    //找到物体组件的路径
    public static T Find<T>(this GameObject parent,string path)
    {
        return parent.transform.Find(path).GetComponent<T>();
    }
    //删除所有的子节点
    public static void DestroyAllChildren(this GameObject parent)
    {
        for (int i = 0; i < parent.transform.childCount; i++)
        {
            var child = parent .transform.GetChild(i);
            GameObject.Destroy(child.gameObject);
        }
    }
}
